package com.itheima.put;

import com.itheima.domain.Student;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Test3 {
    public static void main(String[] args) throws IOException {
//        1. 请定义一个Student类，属性：姓名、性别、年龄、分数
//	   无参、全参构造方法
//	   get/set方法
//	2. 定义测试类，编写main()方法：
//		//1.定义一个集合
//		List<Student> stuList = new ArrayList<>();
//		stuList.add(new Student(“张三”,”男”,20,88);
//		stuList.add(new Student(“李四”,”女”,19,99);
//	3. 遍历这个集合，将每个Student对象中的数据按以下格式写到项目根目录下
//	  的student.txt中：
//	[Student{name='zhangsan', gender='boy',age=20,score=88},
//	Student{name='李四', gender='女',age=19,score=99}]
        List<Student> stuList = new ArrayList<>();
        stuList.add(new Student("zhangsan","boy",20,88));
        stuList.add(new Student("lisi","gir",19,99));
        FileOutputStream fos=new FileOutputStream("student.txt",true);
        int b;
        byte[] bytes=new byte[1024];
        for (Student student : stuList) {
                fos.write(student.toString().getBytes());
                fos.write("\r\n".getBytes());
        }
        fos.close();
    }
}
